﻿
using System;

using OxyPlot;
using OxyPlot.Series;
using OxyPlot.Axes;


namespace DailyFx.UI
{

	public abstract class Chart : View, IChart
	{
		/// <summary>
		///		the oxyplot model for rendering .
		/// </summary>
		protected OxyPlot.PlotModel mModelImpl = null;


		public OxyPlot.PlotModel ModelImpl
		{
			get {
				return this.mModelImpl;
			}
			set {
				this.mModelImpl = value;
				this.RaisePropertyChanged ( () => this.ModelImpl );
			}
		}

		public virtual Int32 Category
		{ 
			get { return 0; }
		}

		
		protected virtual bool AddImpl ( OxyPlot.Series.Series series)
		{
			return false ;
		}
	}

	public class MainChart : Chart
	{

		public MainChart ( String title, Int32 fab ) 
		{
			//// Create the main plot model .
			var model = new OxyPlot.PlotModel( title);

			// Create the time axis .
			//
			var timeAxis = new DateTimeAxis() 
			{ 
				Key = "$Key.", Position = AxisPosition.Bottom,

				CalendarWeekRule = System.Globalization.CalendarWeekRule.FirstFourDayWeek,
				FirstDayOfWeek = System.DayOfWeek.Monday,

				IntervalType = DateTimeIntervalType.Days, // todo: Depends on Fab of series;
				IntervalLength = 200,
				MajorStep = 7,
				StringFormat = "MM/dd/yyyy",
			};

			model.Axes.Add ( timeAxis );

			// Create the Y axis, for Values 
			//
			var yAxis = new LinearAxis ()
			{
				Key = "$BAR.",

				Position = AxisPosition.Left,


				MaximumPadding = 0.0,
				MinimumPadding = 0.0,
			};
			model.Axes.Add( yAxis );


			this.ModelImpl = model;
		}

		public override Int32 Category
		{
			get { return 360; }
		}
	}
}
